<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript">
	$(function() {

		$('#iconCls').combobox({
			data : $.iconData,
			formatter : function(v) {
				return $.formatString('<span class="{0}" style="display:inline-block;vertical-align:middle;width:16px;height:16px;"></span>{1}', v.value, v.value);
			}
		});

		$('#pid').combotree({
			url : '/resourceController/tree',
			parentField : 'pid',
			lines : true,
			value : '0',
			icons:[{
				iconCls:'icon-clear',
				handler: function(e){
					$('#pid').combotree('clear');
				}
			}],
			onLoadSuccess : function() {
				parent.$.messager.progress('close');
				$('#pid').combotree("setText","选择上级资源");
			}
		});

		$('#form').form({
			url : '/resourceController/add',
			onSubmit : function() {
				parent.$.messager.progress({
					title : '提示',
					text : '数据处理中，请稍后....'
				});
				var isValid = $(this).form('validate');
				if (!isValid) {
					parent.$.messager.progress('close');
				}
				return isValid;
			},
			success : function(result) {
				parent.$.messager.progress('close');
				result = $.parseJSON(result);
				if (result.success) {
					parent.$.modalDialog.openner_treeGrid.treegrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_treeGrid这个对象，是因为resource.jsp页面预定义好了
// 					parent.layout_west_tree.tree('reload');
					parent.$.modalDialog.handler.dialog('close');
				}
			}
		});
	});
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false" title="" style="overflow: hidden;">
		<form id="form" method="post">
			<table class="table table-hover table-condensed">
				<tr>
					<input name="id" type="hidden" class="span2" value="" readonly="readonly"/>
					<input name="openFlag" type="hidden" value="1" />
					<th>资源名称</th>
					<td><input name="name" type="text" placeholder="请输入资源名称" class="easyui-validatebox span2"  style="width: 165px; " data-options="required:true" value=""></td>
					<th>资源代码</th>
					<td><input name="code" type="text" placeholder="请输入资源代码" class="span2" value="" style="width: 165px; "></td>
				</tr>
				<tr>
					<th>菜单图标</th>
					<td><input id="iconCls" name="iconPath" style="width: 165px; 	" data-options="editable:false" /></td>
					<th>资源类型</th>
					<td>
						菜单<input name="typeFlag" type="radio" value="1"  checked="checked"/>
						按钮<input name="typeFlag" type="radio" value="2"/>
					</td>
				</tr>
				<tr>
					<th>排序</th>
					<td><input name="sortWeight" value="100" class="easyui-numberspinner" style="width: 165px; height: 29px;" required="required" data-options="editable:false,min:100"></td>
					<th>上级资源</th>
					<td><select id="pid" name="parentId" style="width: 165px; height: 29px;"></select></td>
				</tr>
				<tr>
					<th>资源路径</th>
					<td colspan="3"><input name="address" type="text" placeholder="请输入资源路径" style="width: 435px; " class="easyui-validatebox span2" value=""></td>
					
				</tr>
				<tr>
					<th>备注</th>
					<td colspan="3"><textarea name="remark"  style="width: 435px;" class="span5"></textarea></td>
				</tr>
			</table>
		</form>
	</div>
</div>